<?php

function add_user($username, $password) {
	if (!empty($username) && !empty($password)) {
		$sql = "SELECT count(username) FROM Users WHERE username='" . $username . "';";
		$res = mysql_query($sql);
		$row = mysql_fetch_assoc($res);
		if ($row['count(username)'] == 0) {
			$sql = "INSERT INTO Users (username, passwd)
					VALUES('" . $username . "', '" . $password . "');";
			mysql_query($sql);
			$sql = "INSERT INTO UserProfile (username)
					VALUES('$username');";
			mysql_query($sql);
			return true;
		} else {
			return false;
		}
	} else {
		return false;
	}
}

;?>
